using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using WB.Entity;
using WB.Entity.Helper;
using WB.Library;
namespace WB.DaoHelper
{
	public class NewsDao : NewsDaoBase
	{
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public static NewsDao Instants()
		{
			return new NewsDao();
		}

        public PagedData GetSearch(string title, int pageCurrent)
        {
            string strSQL = "shop_SearchNews";
            Hashtable param = new Hashtable();
            if (!string.IsNullOrEmpty(title))
            {
                param["Title"] = title;
            }

            return GetPagging(strSQL, param, pageCurrent);
        }

        public DataTable GetNews()
        {
            string strSQL = "shop_GetNews";
            return ExecuteDataTable(CommandType.StoredProcedure, strSQL);
        }

        public NewsEntity GetByIntId(int intId)
        {
            NewsEntity tmp = new NewsEntity();
            return (NewsEntity)SelectByKey(tmp, NewsField.IntId, intId);
        }

        public DataTable GetNewsRelation(Guid Id)
        {
            string strSQL = "shop_GetNewsRelation";
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@NewsId", Id);
            return ExecuteDataTable(CommandType.StoredProcedure, strSQL, param);
        }
	}
}
